<template>
  <el-button :loading="exportData.loading" size="small" type="primary" icon="el-icon-download" @click.native="exportDown()">{{ exportData.button }}</el-button>
</template>

<script>
import api, { exportLoad } from '@/api/service'

export default {
  props: {
    bean: {
      type: String,
      default: 'user'
    },
    fileName: {
      type: String,
      default: '导出文件'
    },
    pageSize: {
      type: Number,
      default: 100
    },
    tableMap: {
      type: Object,
      default: () => {}
    },
    params: {
      type: Object,
      default: () => {}
    },
    onFilter: {
      type: Function,
      default: null
    }
  },
  data() {
    return {
      exportData: {
        button: '导出',
        loading: false
      }
    }
  },
  watch: {
    tableMap: {
      handler(newValue, oldValue) {
        console.log('newValue', newValue)
        console.log('oldValue', oldValue)
        // console.log(util.looseEqual(newValue, oldValue))
      },
      deep: true
    }
  },
  mounted() {

  },
  methods: {
    exportDown() {
      exportLoad(api.offsetBy, this.bean, this.fileName, this.pageSize, this.params, this.exportData, this.tableMap, this.onFilter)
    }
  }
}
</script>
